//
//  LifeStyleViewController.m
//  ALFashion
//
//  Created by dengzhicheng on 15/6/15.
//  Copyright (c) 2015年 dengzhicheng. All rights reserved.
//

#import "LifeStyleViewController.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height

@interface LifeStyleViewController ()

@end

@implementation LifeStyleViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)loadView
{
    [super loadView];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    self.navigationController.navigationBar.translucent = NO;
    
    [self setNavigation];
    [self createSubView];
    
}

// 设置导航栏
- (void)setNavigation
{
    // 自定义view, 添加到导航栏的titleView上
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleView.frame];
    titleLabel.text = @"ALFashion";
    titleLabel.font = [UIFont fontWithName:@"huxiaobo-gdh" size:30];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [titleView addSubview:titleLabel];
    self.navigationItem.titleView = titleView;
    
    // 自定义button, 添加到导航栏的leftButtonItem上
    UIButton *menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 5, 20, 20)];
    [menuButton setImage:[UIImage imageNamed:@"menu.png"] forState:UIControlStateNormal];
    [menuButton setImage:[UIImage imageNamed:@"menuSelected.png"] forState:UIControlStateHighlighted];
    [menuButton addTarget:self action:@selector(menuButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuButton];
}

// menu 按钮点击事件
- (void)menuButtonClicked:(UIButton *)button
{
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MenuView" object:@(YES)];
    
}

- (void)createSubView
{
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 20)];
    [label setBackgroundColor:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1]];
    label.text = @"生活  LIFESTYLE";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:12];
    label.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:label];
}

@end
